<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>物流过程</title>
    <link href="../../css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="../../font-awesome/css/font-awesome.css?v=4.3.0" rel="stylesheet">
    <link href="../../css/animate.css" rel="stylesheet">
    <link href="../../css/style.css?v=2.2.0" rel="stylesheet">
</head>
<body class="top-navigation">
<div id="wrapper">
    <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom white-bg">
            <nav class="navbar navbar-static-top" role="navigation">
                <div class="navbar-header">
                    <button aria-controls="navbar" aria-expanded="false" data-target="#navbar" data-toggle="collapse" class="navbar-toggle collapsed" type="button">
                        <i class="fa fa-reorder"></i>
                    </button>
                    <a href="Logistics_navigation.html" class="navbar-brand">PIE</a>
                </div>
                <div class="navbar-collapse collapse" id="navbar">
                    <ul class="nav navbar-nav">
                        <li class="active">
                            <a aria-expanded="false" role="button" href="Logistics_navigation.html"> 返回主页</a>
                        </li>
                    </ul>
                    <ul class="nav navbar-top-links navbar-right">
                        <li id="logout">
                            <a href="">
                                <i class="fa fa-sign-out"></i> 退出
                            </a>
                        </li>
                    </ul>
                </div>
            </nav>
        </div>


        <div class="middle-box text-center loginscreen   animated fadeInDown">
            <div class="ibox-content">
                <div>
                    <h3 class="">物流过程</h3>
                </div>
                <form class="m-t" role="form"  id="form">
                    <div class="form-group">
                        <textarea class="form-control col-lg-8" id="message" name="Message" rows="3" placeholder="请输入13位小猪的ID，以;隔开。"></textarea>
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="请输入车牌号（如：京P1234A）" required="" id="carid" name="Carid">
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="请输入湿度(如：12.22)" required="" id="humidity" name="Humidity">
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="请输入温度(如：12.22)" required="" id="temperature" name="Temperature">
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="请输入CO2浓度(如：12.22)" required="" id="co2" name="Co2">
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="请输入当前位置" required="" id="location" name="Location">
                    </div>

                    <button type="button" class="btn btn-primary block full-width m-b" id="btnlw">提交</button>
                    </p>
                </form>
            </div>
        </div>



        <div class="footer">
            <div class="pull-right">
                PIE
            </div>
            <div>
                <strong>Copyright</strong> H+ &copy; 2014
            </div>
        </div>

    </div>
</div>




    <!-- Mainly scripts -->
    <script src="../../js/jquery-3.3.1.js"></script>
    <script src="../../js/bootstrap.min.js?v=3.4.0"></script>
    <script src="../../js/plugins/validate/jquery.validate.min.js"></script>
    <script src="../../js/plugins/validate/messages_zh.min.js"></script>

    <script>
        $(function(){
            $(document).ready(function(){
                $("#btnlw").click(function(){
                    var transportTime=new Date();
                    var t=transportTime.toLocaleString();
                    //alert(str);

                    var lw = {
                        id: $("#message").val(),
                        carId: $("#carid").val(),
                        humidity: $("#humidity").val(),
                        temperature: $("#temperature").val(),
                        co2: $("#co2").val(),
                        location: $("#location").val(),
                        transportTime: t

                    }
                    var LW=JSON.stringify(lw);
                    //alert(Pig);
                    $.post({
                        url: "http://localhost:8080/logisticsoperation",
                        headers: {
                            "Content-Type": "application/json; charset=utf-8"
                        }
                    }, LW,function (data){
                        if(data=="请先登录")
                        {
                            alert(data);
                            location.assign("http://localhost:8080/PorkTraceability/login/Login.html");
                        }
                        else {
                            alert(data);
                            location.reload();
                        }
                    })
                });
            });
        });

    </script>
    <script>
        $(document).ready(function () {
            $("#form").validate({
                rules:{
                    Message:{
                        required:true
                    },
                    Carid:{
                        required:true,
                        maxlength:7,
                        minlength:7
                    },
                    Humidity:{
                        required:true,
                        maxlength:5
                    },
                    Temperature:{
                        required:true,
                        maxlength:5
                    },
                    Co2:{
                        required:true,
                        maxlength:5
                    },
                    Location:{
                        required:true
                    }
                }
            })
        })
    </script>
<script>
    $("#logout").click(function(){
        $.get("http://localhost:8080/logout",function () {
            location.assign("http://localhost:8080/PorkTraceability/login/Login.html");
        })
    })
</script>

</body>
</html>



